<%@ page import="com.zwy.ubts.service.OrderService" %>
<%@ page import="com.zwy.ubts.service.impl.OrderServiceImpl" %>
<%@ page import="com.zwy.ubts.service.BookService" %>
<%@ page import="com.zwy.ubts.service.impl.BookServiceImpl" %><%--
  Created by IntelliJ IDEA.
  User: Zhou Wenying
  Date: 2023/4/4
  Time: 16:41
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page isELIgnored="false" %>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>旧书交易平台</title>
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="pragma" content="no-cache">
    <link rel="stylesheet" href="/static/css/Cart.css">
</head>

<%--style="background-color: aliceblue;"--%>
<body >
<jsp:include page="/page/head2.jsp"></jsp:include>

<!-- 订单部分 -->
<div class="layui-row">
            <div class="layui-col-md1 layui-col-md-offset1">
                <div class="indent boxS">
                    <div class="indentAea w1190">
                        <h2 class="Contitle">我的订单</h2>
                    </div>
                </div>
            </div>
            <div class="layui-col-md11 layui-col-md-offset1">
                <div class="layui-row grid-demo">
                    <div class="layui-col-md8">

<%--                        <button type="button" class="layui-btn layui-btn-primary layui-btn-radius">已发货</button>--%>
<%--                        <button type="button" class="layui-btn layui-btn-radius">默认按钮</button>--%>
<%--                        <button type="button" class="layui-btn layui-btn-normal layui-btn-radius">百搭按钮</button>--%>
<%--                        <button type="button" class="layui-btn layui-btn-warm layui-btn-radius">暖色按钮</button>--%>
<%--                        <button type="button" class="layui-btn layui-btn-danger layui-btn-radius">警告按钮</button>--%>
<%--                        <button type="button" class="layui-btn layui-btn-disabled layui-btn-radius">禁用按钮</button>--%>

                        <div class="layui-panel">
                            <span style="padding:15px 15px 5px ">我的购买</span>
                            <%--                    <a style="float: right;padding-right: 10px;color: #0a9dbd">更多>></a>--%>
                            <table class="layui-table">
                                <colgroup>
                                    <col width="150">
                                    <col width="90">
                                    <col width="80">
                                    <col>
                                    <col width="90">
                                    <col width="100">
                                    <col>
                                </colgroup>
                                <thead>
                                <tr>
                                    <th>订单号</th>
                                    <th>书籍名称</th>
                                    <th>价格</th>
                                    <th>创建时间</th>
                                    <th>订单状态</th>
                                    <th>运单号</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody id="mySellBook">
                                <c:forEach items="${buyOrders}" var="Owner">
                                    <c:forEach items="${Owner.booksList}" var="book">
                                        <tr>
                                            <td>${Owner.orderId}</td>
                                            <td>${book.bookName}</td>
                                            <td>${book.bookMoney}</td>
                                            <td>${Owner.orderCretime}</td>
                                                <%--是等待发货，1 部分发货 2全部运送中 3订单完成--%>
                                            <c:if test="${book.status.state == 0}">
                                                <td style="color: blue">等待发货</td>
                                                <td>无</td>
                                                <td>
                                                    等待发货
                                                </td>
                                            </c:if>
                                            <c:if test="${book.status.state == 1}">
                                                <td style="color: #2eff11">运送中</td>
                                                <td>${book.status.kd}</td>
                                                <td>
                                                    <a type="button" href="/doMyOrderBuy?orderId=${Owner.orderId}&bookId=${book.bookId}" class="layui-btn layui-btn-radius">确认收货</a>
                                                </td>
                                            </c:if>
                                            <c:if test="${book.status.state == 2}">
                                                <td style="color: green">订单完成</td>
                                                <td>${book.status.kd}</td>
                                                <td>
                                                    完成交易
                                                </td>
                                            </c:if>

                                        </tr>
                                    </c:forEach>
                                </c:forEach>
                                </tbody>
                            </table>
                            <div id="mySellBookPage">

                            </div>
                        </div>
                    </div>
                </div>

            </div>
</div>

<%--发货弹框--%>
<div id="PopSell" class="modal fade" tabindex="-1">
    <div class="modal-dialog">
        <div style="background-color: #fff;">
            <div style="padding: 15px;" class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">系统弹窗</h4>
            </div>
            <div class="modal-body">
                <div class="row clearfix">
                    <div class="form-group" style="padding: 15px">
                        <label class="col-sm-2 control-label">运单号</label>
                        <div class="col-sm-10">
                            <input id="modalYDH" type="text" class="form-control"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button id="modelOK" type="button" class="btn btn-default btn-success">发货</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>


</body>

<!-- 底部 -->
<jsp:include page="footer.jsp"></jsp:include>

</html>

<script src="/static/js/layui-page.js"></script>
<script src="/static/js/bootstrap-pop.js"></script>

<script>
    var page = new LayuiPage("#mySellBook","#mySellBookPage",8,0);

    var m_orderId;
    var m_bookId;
    function sellOrders(orderId,bookId) {
        m_orderId = orderId;
        m_bookId = bookId;
        $("#PopSell").modal("show");//hide
    }
    $("#modelOK").click(function () {

        var ydh = $("#modalYDH").val();
        // var obj = {};
        // var json = JSON.stringify(obj);
        console.log("/doMyOrderSell?orderId="+m_orderId+"&bookId="+m_bookId+"&ydh="+ydh)
        $.ajax({
            url:"/doMyOrderSell?orderId="+m_orderId+"&bookId="+m_bookId+"&ydh="+ydh,
            type:"post",
            dataType:"json",
            //data:json,
            contentType: false,
            success:function (json) {
                console.log(json);
                //var obj = JSON.parse(data);
                if (json.ret == 'true'){
                    layer.msg(json.data);
                    window.location.href="/myOrderSell";

                }else {
                    layer.msg(json.data);
                }
            },
            error:function (data) {

            }
        });
    });


</script>

